#!/usr/bin/env node

const fs = require('fs');
const path = require('path');

const dir = process.argv[2] ?
path.resolve(process.argv[2]) : __dirname;

// 检查目录是否存在
if (!fs.existsSync(dir)) {
    console.error(`Error: Directory "${dir}" does not exist.`);
  } else {
    // 读取目录内容并打印
    try {
      const files = fs.readdirSync(dir);
      console.log(files);
    } catch (error) {
      console.error(`Error: Unable to read directory "${dir}": ${error.message}`);
    }
  }